import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class test1 {
    public class ProvinceCitySelector {
        public static void main(String[] args) {
            // 创建一个省份和城市的数据结构
            Map<String, String[]> provinceCityMap = new HashMap<>();
            provinceCityMap.put("北京", new String[]{"北京市"});
            provinceCityMap.put("上海", new String[]{"上海市"});
            provinceCityMap.put("广东", new String[]{"广州市", "深圳市", "珠海市"});
            // ... 添加更多省份和城市

            // 获取用户输入的省份
            Scanner scanner = new Scanner(System.in);
            System.out.println("请输入省份：");
            String province = scanner.nextLine();

            // 根据省份显示对应的城市
            if (provinceCityMap.containsKey(province)) {
                String[] cities = provinceCityMap.get(province);
                System.out.println("请选择城市：");
                for (int i = 0; i < cities.length; i++) {
                    System.out.println((i + 1) + ". " + cities[i]);
                }
                int cityIndex = scanner.nextInt() - 1;
                if (cityIndex >= 0 && cityIndex < cities.length) {
                    System.out.println("您选择了：" + cities[cityIndex]);
                } else {
                    System.out.println("无效的城市选择，请重新输入。");
                }
            } else {
                System.out.println("无效的省份输入，请重新输入。");
            }
            scanner.close();
        }
    }
}
